﻿namespace IOP.Protocols.MQTT
{
    /// <summary>
    /// 主题过滤器
    /// </summary>
    public struct TopicFilter
    {
        private string _FilterName;
        /// <summary>
        /// 过滤器名
        /// </summary>
        public string FilterName
        {
            get { return _FilterName == null ? string.Empty : _FilterName; }
            set { _FilterName = value; }
        }

        /// <summary>
        /// 请求质量
        /// </summary>
        public QoSType RequestedQoS { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="name"></param>
        /// <param name="qoS"></param>
        public TopicFilter(string name, QoSType qoS)
        {
            _FilterName = name;
            RequestedQoS = qoS;
        }

        /// <summary>
        /// 获取长度
        /// </summary>
        /// <returns></returns>
        public int GetLength()
        {
            return FilterName.Length + sizeof(ushort) + 1;
        }
    }
}
